package com.ruoyi.business.service.impl;

import java.util.List;

import com.ruoyi.business.domain.vo.BusNeighborhoodVo;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.stereotype.Service;
import com.ruoyi.business.mapper.BusNeighborhoodLedgerMapper;
import com.ruoyi.business.domain.BusNeighborhoodLedger;
import com.ruoyi.business.service.IBusNeighborhoodLedgerService;
import javax.annotation.Resource;

/**
 * 小区台账Service业务层处理
 *
 * @author ling
 * @date 2024-07-12
 */
@Service
public class BusNeighborhoodLedgerServiceImpl implements IBusNeighborhoodLedgerService
{
    @Resource
    private BusNeighborhoodLedgerMapper busNeighborhoodLedgerMapper;

    /**
     * 查询小区台账
     *
     * @param id 小区台账主键
     * @return 小区台账
     */
    @Override
    public BusNeighborhoodLedger selectBusNeighborhoodLedgerById(Long id)
    {
        return busNeighborhoodLedgerMapper.selectBusNeighborhoodLedgerById(id);
    }

    /**
     * 查询小区台账列表
     *
     * @param busNeighborhoodLedger 小区台账
     * @return 小区台账
     */
    @Override
    public List<BusNeighborhoodLedger> selectBusNeighborhoodLedgerList(BusNeighborhoodLedger busNeighborhoodLedger)
    {
//
        return busNeighborhoodLedgerMapper.selectBusNeighborhoodLedgerList(busNeighborhoodLedger);
    }

    /**
     * 获取调压设施数量、缸数量、闸数量、楼栋数后的集合
     *
     * @param busNeighborhoodLedger
     * @return {@link List }<{@link BusNeighborhoodVo }>
     */
    @Override
    public List<BusNeighborhoodVo> selectBusNeighborhoodLedgerListAB(BusNeighborhoodLedger busNeighborhoodLedger) {

        List<BusNeighborhoodVo> busNeighborhoodVo = busNeighborhoodLedgerMapper.selectBusNeighborhoodLedgerListAB(busNeighborhoodLedger);
//        获取调压设施数量，遍历集合
//        busNeighborhoodVo.forEach(busNeighborhoodVo1 -> {
//
//        });

//        更新表中的调压设施数量

        return busNeighborhoodVo;
    }

    /**
     * 新增小区台账
     *
     * @param busNeighborhoodLedger 小区台账
     * @return 结果
     */
    @Override
    public int insertBusNeighborhoodLedger(BusNeighborhoodLedger busNeighborhoodLedger)
    {
        busNeighborhoodLedger.setCreateUser(SecurityUtils.getUserId());
        busNeighborhoodLedger.setCreateBy(SecurityUtils.getUsername());
        busNeighborhoodLedger.setCreateTime(DateUtils.getNowDate());
        busNeighborhoodLedger.setUpdateUser(SecurityUtils.getUserId());
        busNeighborhoodLedger.setUpdateBy(SecurityUtils.getUsername());
        busNeighborhoodLedger.setUpdateTime(DateUtils.getNowDate());
        return busNeighborhoodLedgerMapper.insertBusNeighborhoodLedger(busNeighborhoodLedger);
    }

    /**
     * 修改小区台账
     *
     * @param busNeighborhoodLedger 小区台账
     * @return 结果
     */
    @Override
    public int updateBusNeighborhoodLedger(BusNeighborhoodLedger busNeighborhoodLedger)
    {
        busNeighborhoodLedger.setUpdateUser(SecurityUtils.getUserId());
        busNeighborhoodLedger.setUpdateBy(SecurityUtils.getUsername());
        busNeighborhoodLedger.setUpdateTime(DateUtils.getNowDate());
        return busNeighborhoodLedgerMapper.updateBusNeighborhoodLedger(busNeighborhoodLedger);
    }

    /**
     * 批量删除小区台账
     *
     * @param ids 需要删除的小区台账主键
     * @return 结果
     */
    @Override
    public int deleteBusNeighborhoodLedgerByIds(Long[] ids)
    {
        return busNeighborhoodLedgerMapper.deleteBusNeighborhoodLedgerByIds(ids);
    }

    /**
     * 删除小区台账信息
     *
     * @param id 小区台账主键
     * @return 结果
     */
    @Override
    public int deleteBusNeighborhoodLedgerById(Long id)
    {
        return busNeighborhoodLedgerMapper.deleteBusNeighborhoodLedgerById(id);
    }

    /**
     * 功能描述：获取num
     *
     * @return {@link Integer }
     * @author ling
     * @date 2024/08/22 15:28
     */
    @Override
    public Integer getCount() {
        return busNeighborhoodLedgerMapper.getCount();
    }

    @Override
    public Integer updateBusNeighborhoodLedgers(List<BusNeighborhoodLedger> busNeighborhoodLedgerList) {
        return busNeighborhoodLedgerMapper.updateBusNeighborhoodLedgers(busNeighborhoodLedgerList);
    }
}
